package leetcode.editor.cn.q0xx

import kotlin.math.max

class Q53 {
    fun maxSubArray(nums: IntArray): Int {
        if (nums.isEmpty()) return 0
        var cur = 0
        var max = nums[0]
        for (n in nums) {
            cur = max(cur + n, n)
            max = max(max, cur)
        }
        return max
    }
}